#include "ResourceCacheProcess.h"

namespace re
{
	namespace io
	{
		void ResourceCacheProcess::Update()
		{
			core::EventDataPtr data;
			listener_->queue_.wait_pop(data);
			//handle data
			if(data->VGetEventTypeId() == core::LoadFileRequest::eventtype_)
			{
				core::LoadFileRequest * rqst = reinterpret_cast<core::LoadFileRequest*>(data.get());
				rescache_.GetResource(rqst->filename);
				GetEventManager()->VTriggerEvent(core::EventDataPtr(new core::LoadFileResult(rqst->filename)));
			}
		}
		void ResourceCacheProcess::Initialize()
		{
			listener_ = new core::RealtimeEventListener;
			listener_holder_ = core::EventListenerPtr(listener_);
			core::IEventManager::GetGlobal()->VRegisterListener(listener_holder_);
		}
		void ResourceCacheProcess::ShutDown()
		{
			
		}
	}
}